<?php
class MaquinariasController extends AppController{

	public $layout = 'default';
    public $name = 'Maquinarias';
    public $uses = array('Maquinaria');
    public $helpers = array('Html', 'Form');
    public $components = array('Session');

	public function index(){
	 $this->paginate = array('Maquinaria' => array('limit' => 95));
//       debug( $this->paginate('Maquinaria'));
       $this->set('data', $this->paginate('Maquinaria'));
	}
	public function insertar(){
	
	if(!empty($this->data)):
            if ($this->Maquinaria->save($this->data)) {
                $this->Session->setFlash('Registro de Maquinaria completado');
                $this->redirect(array('action' => 'index'), null, true);
            } else {
                $this->Session->setFlash('No se pudo registrar la maquinaria!!!!!');
                $this->redirect(array('action' => 'index'), null, true);
            }
    endif;
	}
	function editar($id = null){
               
      $this->Maquinaria->id = $id;
      if (!$id) {
         $this->Session->setFlash('No existe tal registro');
         $this->redirect(array('action' => 'index'), null, true);
                }
      if (empty($this->data)) {
         $this->data = $this->Maquinaria->read(); 
    //     debug($this->data);exit;
      } else {
        if ($this->Maquinaria->save($this->data)) {
        $this->Session->setFlash('Los datos fueron modificados');
         $this->redirect(array('action' => 'index'), null, true);
        } else {
        $this->Session->setFlash('no se pudo modificar!!');
                }
      }
    }
}
?>
